package com.common.service;

import org.springframework.web.socket.CloseStatus;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketSession;
import org.springframework.web.socket.handler.AbstractWebSocketHandler;

/**
 * @classDescription:
 * @author:xiayingjie
 * @createTime:16/8/17
 */

public class WebSocketTest extends AbstractWebSocketHandler {

    //处理消息
    protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
        Thread.sleep(1000);
        System.out.println(message.toString());
        session.sendMessage(new TextMessage("mygood!"));
    }
    //关闭连接
    public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception {
        System.out.println("i goout");
    }

    //连接
    public void afterConnectionEstablished(WebSocketSession session) throws Exception {
        System.out.println("i comein");
    }



}
